#include "sourcedock.h"
#include "sourcetree.h"

#include <QtCore/qtimer.h>

SourceDock::SourceDock(DokerModel *model, QWidget *parent) :
    QDockWidget(tr("Source Tree"), parent)
{
    m_tree = new SourceTree(model, this);
    setWidget(m_tree);
}

void SourceDock::clear()
{
    m_tree->clear();
}

void SourceDock::restoreMinMaxSizes()
{
    setMinimumWidth(m_oldMinWidth);
    setMaximumWidth(m_oldMaxWidth);
}

void SourceDock::setWidth(int w)
{
    m_oldMinWidth = minimumWidth();
    m_oldMaxWidth = maximumWidth();
    if (w > 0)
    {
        if (width()< w)
            setMinimumWidth(w);
        else
            setMaximumWidth(w);
    }
    QTimer::singleShot(1, this, SLOT(restoreMinMaxSizes()));
}
